Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

246
Views
js error : "'createObjectURL' on 'URL': Overload resolution failed."

I try to display an image on a php page in js, knowing that my image via an input file. here is my code:

<script>
  function image(){
    var x = document.getElementById("image_uploads");
    var test = URL.createObjectURL(x);
    //document.getElementById("img").src = URL.createObjectURL(x);
    }
</script>

<body>
  <div class="frItem31">
    <form name="saisie" action="" method="post">
      Image 1 :<input type="file" id="image_uploads" class="image_uploads" name="image_uploads" accept="image/*"/> 
      <br>
       <img id="img" class="img">
       <br>
       <input type="button" id="calcVitesse" class="calcVitesse" value="calculer la vitesse" onclick="image()">
    </form>
  </div>
</body>

here is the error I get:

Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.
    at image (image.php:20:32)
    at HTMLInputElement.onclick (image.php:80:125)
image @ image.php:20
onclick @ image.php:80

Could you help me please !?!

G.B.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you're passing an HTML element instead of a file. To get the file, use .files property, which behaves like an Array, so you can iterate it. see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#getting_information_on_selected_files

try this:

  function image() {
    var x = document.getElementById("image_uploads");
    if (x.files.length) {
        var test = URL.createObjectURL(x.files[0]);
    }

  }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!